themingengine: refactor a conditional branch
authorCosimo Cecchi <cosimoc@gnome.org>
Sun, 4 Aug 2013 07:32:14 +0000 (09:32 +0200)
committerCosimo Cecchi <cosimoc@gnome.org>
Tue, 20 Aug 2013 00:50:40 +0000 (02:50 +0200)
Return early when the state is not wildcarded - makes the code more
readable.

https://bugzilla.gnome.org/show_bug.cgi?id=705443

gtk/gtkthemingengine.c

index d47b7d2a42256fa2b92020fb05fc016cbd5912a2..d7466e6629a47ef91b843f4427f21d37d9bdf3f7 100644 (file)
@@ -2732,45 +2732,43 @@ gtk_theming_engine_render_icon_pixbuf (GtkThemingEngine    *engine,
   wildcarded = gtk_icon_source_get_state_wildcarded (source);
   G_GNUC_END_IGNORE_DEPRECATIONS;
 
-  if (wildcarded)
+  if (!wildcarded)
+    return scaled;
+
+  if (state & GTK_STATE_FLAG_INSENSITIVE)
     {
-      if (state & GTK_STATE_FLAG_INSENSITIVE)
-        {
-         surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32,
-                                               gdk_pixbuf_get_width (scaled),
-                                               gdk_pixbuf_get_height (scaled));
-         cr = cairo_create (surface);
-         gdk_cairo_set_source_pixbuf (cr, scaled, 0, 0);
-         cairo_paint_with_alpha (cr, 0.5);
-
-         cairo_destroy (cr);
-
-         g_object_unref (scaled);
-         stated = gdk_pixbuf_get_from_surface (surface, 0, 0,
-                                               cairo_image_surface_get_width (surface),
-                                               cairo_image_surface_get_height (surface));
-         cairo_surface_destroy (surface);
-        }
-      else if (state & GTK_STATE_FLAG_PRELIGHT)
-        {
-         surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32,
-                                               gdk_pixbuf_get_width (scaled),
-                                               gdk_pixbuf_get_height (scaled));
+      surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32,
+                                           gdk_pixbuf_get_width (scaled),
+                                           gdk_pixbuf_get_height (scaled));
+      cr = cairo_create (surface);
+      gdk_cairo_set_source_pixbuf (cr, scaled, 0, 0);
+      cairo_paint_with_alpha (cr, 0.5);
+
+      cairo_destroy (cr);
+
+      g_object_unref (scaled);
+      stated = gdk_pixbuf_get_from_surface (surface, 0, 0,
+                                           cairo_image_surface_get_width (surface),
+                                           cairo_image_surface_get_height (surface));
+      cairo_surface_destroy (surface);
+    }
+  else if (state & GTK_STATE_FLAG_PRELIGHT)
+    {
+      surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32,
+                                           gdk_pixbuf_get_width (scaled),
+                                           gdk_pixbuf_get_height (scaled));
 
-         cr = cairo_create (surface);
-         gdk_cairo_set_source_pixbuf (cr, scaled, 0, 0);
-         colorshift_source (cr, 0.10);
+      cr = cairo_create (surface);
+      gdk_cairo_set_source_pixbuf (cr, scaled, 0, 0);
+      colorshift_source (cr, 0.10);
 
-         cairo_destroy (cr);
+      cairo_destroy (cr);
 
-         g_object_unref (scaled);
-         stated = gdk_pixbuf_get_from_surface (surface, 0, 0,
-                                               cairo_image_surface_get_width (surface),
-                                               cairo_image_surface_get_height (surface));
-         cairo_surface_destroy (surface);
-        }
-      else
-        stated = scaled;
+      g_object_unref (scaled);
+      stated = gdk_pixbuf_get_from_surface (surface, 0, 0,
+                                           cairo_image_surface_get_width (surface),
+                                           cairo_image_surface_get_height (surface));
+      cairo_surface_destroy (surface);
     }
   else
     stated = scaled;